<?php

/**
 * 会员中心
 * Some rights reserved：abc3210.com
 * Contact email:admin@abc3210.com
 */
class BuyAction extends MemberbaseAction {

        private $goodsobj;
        private $orderobj;
        private $theuid;
        function _initialize() {
            parent::_initialize();
            import('Form');
            $group = F("Member_group");
            $Model_Member = F("Model_Member");
            $this->assign("Member_group", $group);
            $this->assign("Model_Member", $Model_Member);
            $this->goodsobj = D('Goods');
            $this->orderobj = M('Order');
            $this->theuid=AppframeAction::$Cache[uid];
        }


        //订单列表
        public function mybuyorders(){

            //$map[uid]=$this->theuid;
            $count = $this->orderobj->where("uid=".$this->theuid)->count();
            $page = $this->page($count, 12);
            $list = $this->orderobj->where("uid=".$this->theuid)->limit($page->firstRow . ',' . $page->listRows)->order('addtime desc')->select();
            foreach ($list as $key => $val) {
                $map['userid'] = $val['uid'];
                $user = M('Member')->field('userid,username')->where($map)->find();
                $list[$key]['username'] = $user['username'];
                $list[$key]['ispayname'] = $this->getOrderStatus($val['ispay']);
            }
            $this->assign('list',$list);
            $this->assign("Page", $page->show('Admin'));
            $this->assign("theuid",$this->theuid);
            $this->display();
        }
        //获得状态说明
        function getOrderStatus($staus){
            switch ($staus) {
                case '0':
                    $val = '未付款';
                    break;
                case '1':
                    $val = '等待买家付款';
                    break;
                case '2':
                    $val = '已付款，等待卖家发货';
                    break;
                case '3':
                    $val = '已发货，等待买家确认';
                    break;
                case '4':
                    $val = '交易成功';
                    break;
                default:
                    $val = '';
                    break;
            }
            return $val;
        }
}

?>
